package com.echo.im.infrastructure.generator;

import com.echo.im.common.contant.RedisConstants;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 *
 * @author echo
 * @date 2024-08-18
 */
@Component
@RequiredArgsConstructor
public class IdGenerator {

    private final RedisTemplate<String, Object> redisTemplate;

    public Long getMsgId() {
        return redisTemplate.opsForValue().increment(RedisConstants.REDIS_MSG_ID_GENERATOR_KEY);
    }

}
